// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
// 配置axios
import Axios from 'axios'
// 配置mintui
import MintUI from 'mint-ui'
// 引入css
import 'mint-ui/lib/style.css'
import '@/assets/public.css'
import MyUL from '@/components/common/MyUL'
import MyLI from '@/components/common/MyLI'
// 定义全局组件
Vue.component(MyUL.name, MyUL)
Vue.component(MyLI.name, MyLI)
// 轮播组件
import Swiper from '@/components/common/Swiper'
Vue.component(Swiper.name, Swiper)
// 评论组件
import Common from '@/components/common/Common'
Vue.component(Common.name, Common)
import NavBar from '@/components/common/NavBar'
Vue.component(NavBar.name, NavBar)
// 定义moment全局日期过滤器
import Moment from 'moment';
Vue.filter('convertTime',function(data,formatStr){
    return Moment(data).format(formatStr);
})
Moment.locale('zh-cn')
Vue.filter('relativeTime',function(data) {
    return Moment(data).fromNow();
});
// 字符串截取过滤器
Vue.filter('converStr',function(str,num){
  return str.substring(0,num) + '...';
});
// 引入图片浏览插件
import VuePreview from 'vue-preview'
Vue.use(VuePreview);

// 配置公共URL
// Axios.defaults.baseURL = 'http://www.sinya.online/api/'
Vue.prototype.$axios = Axios

Axios.interceptors.request.use(
    config => {
        MintUI.Indicator.open({
          text: '加载中...',
          spinnerType: 'fading-circle'
        });
        return config
    }
);
Axios.interceptors.response.use(response => {
    MintUI.Indicator.close();
    return response
})

Vue.use(MintUI)
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
